// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/efficiency/api/EnergyCharcoalMappingApi'

import InfoClass from '@api/efficiency/model/EnergyCharcoalMappingQueryReq'
import EditClass from '@api/efficiency/model/EnergyCharcoalMappingSaveReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  async getInfo(param, TIP = '查询换算规则') {
    const DTO = CORE.grpcDTO(InfoClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'energyCharcoalMappingQuery', DTO)
    return (resp.content || [])[0] || {}
  },

  // —————————————————————————————— 改 —————————————————————————————— //

  transEdit(one, { state: { info } }) {
    return info
  },
  async edit(one, TIP = '修改换算规则') {
    const DTO = CORE.grpcDTO(EditClass, one)
    await CORE.grpc(TIP, CLIENT, 'energyCharcoalMappingSave', DTO)
    return CORE.grpcOK(TIP)
  },
}
